<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>大嘿嘿后台管理</title>
		<link rel="stylesheet" type="text/css" href="css/bootstrap.css" />
		<script src="js/jquery-1.12.4.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/bootstrap.js" type="text/javascript" charset="utf-8"></script>
		
		<script src="js/vue.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/antd.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/axios-0.18.0.js" type="text/javascript" charset="utf-8"></script>
		<script src="js/interfaceuRL.js" type="text/javascript" charset="utf-8"></script>
	</head>
	<body>
		<div id="app">
		  <form class="form-horizontal">
		    <div class="form-group">
		      <label for="inputPassword3" class="col-sm-2 control-label">添加类型</label>
		      <div class="col-sm-10">
		        <input type="text" class="form-control" id="gname" placeholder="">
		      </div>
		    </div>
		    <div class="form-group">
		      <label for="inputPassword3" class="col-sm-2 control-label">分类详情</label>
		      <div class="col-sm-10">
				 <input type="text" class="form-control"id="detail" placeholder="" />
		      </div>
		    </div>
			<div class="form-group">
			  <label for="inputPassword3" class="col-sm-2 control-label">已有分类</label>
			  <div class="col-sm-10">
				 <select name="type" id="type" class="form-control">
					<option value="type" v-for="item in type" :value="item.gid">{{item.gname}}</option>
				  </select>
			  </div>
			</div>
			<div class="form-group">
			  <label for="inputEmail3" class="col-sm-2 control-label">分类标识</label>
			  <div class="col-sm-10">
				<input type="text" class="form-control" id="type1" >
			  </div>
			</div>
		    <div class="form-group">
		      <div class="col-sm-offset-2 col-sm-10">
		       <button type="button" @click="insert()" class="btn btn-primary " >保存</button>
		      <button type="submit" class="btn btn-default" onclick="wenzgl.html" >取消</button>
		      </div>
		    </div>
		  </form>
		
			
		 </div>
		 
	</body>
</html>
<script type="text/javascript">
	var vm = new Vue({
		el: "#app",
		data: {
			type:[],
		},
		beforeMount:function(){
			var _this=this;
			axios({
			   //请求方式，'GET'或者'POST'
			    method: 'GET',
			    //请求地址
			    url: findCatelog()
			}).then(res => {
			     	_this.type=res.data;
					
			}).catch(err => {
				alert("服务出错了!")
				
			  });
		},
		methods: {
			insert: function() {
				if($("#gname").val()==""){
					alert("文章主题不能为空！！！")
				}else{
				axios({
					method:"POST",
					url:Catelogadd(),
					data:{
						"gname":$("#gname").val(),
						"detail":$("#detail").val(),
						"type":$("#type").val(),
						"author":sessionStorage.getItem("supername"),
						"superid":sessionStorage.getItem("superid"),
						
					},

				}).then(res => {
					console.log(res.data);
					
					window.location.href="flguanli.html"
				}).catch(err => {
					alert("服务出错了！")
				})
				
				}			
			}
			
		},
		
	})
</script>
